<?php

namespace iBrand\Shop\Server\Providers;

use iBrand\Shop\Server\Http\Middleware\ClerkMiddleware;
use Route;
use Illuminate\Routing\Router;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;

class RouteServiceProvider extends ServiceProvider
{

	/**
	 * This namespace is applied to your controller routes.
	 *
	 * In addition, it is set as the URL generator's root namespace.
	 *
	 * @var string
	 */
	protected $namespace = 'iBrand\Shop\Server\Controllers';

	public function register()
	{
		$this->app[Router::class]->aliasMiddleware('O2O', ClerkMiddleware::class);
	}

	/**
	 * Define the routes for the application.
	 *
	 * @return void
	 */
	public function map()
	{
		$this->mapApiV2Routes();
	}

	/**
	 *
	 */
	private function mapApiV2Routes()
	{
		Route::prefix('api/v2')
			->middleware('api')
			->namespace($this->namespace . '\V2')
			->group(__DIR__ . '/../routes/api.v2.php');
	}
}
